package com.yc.shopping.ui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.yc.shopping.util.ShoppingUtil;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class AdminMainUI {

	protected Shell shell;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			AdminMainUI window = new AdminMainUI();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
		shell.setSize(561, 748);
		//窗口标题部分显示当前登录用户信息 账号-类型
		shell.setText("源辰收银系统后台");
		shell.setMaximized(true);
		
		Menu menu = new Menu(shell, SWT.BAR);
		shell.setMenuBar(menu);
		
		MenuItem menuItem = new MenuItem(menu, SWT.CASCADE);
		menuItem.setText("库存管理");
		
		Menu menu_1 = new Menu(menuItem);
		menuItem.setMenu(menu_1);
		
		MenuItem menuItem_1 = new MenuItem(menu_1, SWT.NONE);
		//
		menuItem_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				//创建一个对话框	打开对话框 对话框独立类
				
				Dialog_AddGoods add = new Dialog_AddGoods(shell,SWT.CLOSE|SWT.APPLICATION_MODAL);
				add.open();
				
			}
		});
		menuItem_1.setText("录入商品基本信息");
		
		MenuItem menuItem_2 = new MenuItem(menu_1, SWT.NONE);
		menuItem_2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Dialog_FindGoods find = new Dialog_FindGoods(shell,SWT.CLOSE|SWT.APPLICATION_MODAL);
				find.open();
			}
		});
		menuItem_2.setText("浏览商品基本信息");
		
		MenuItem menuItem_3 = new MenuItem(menu_1, SWT.NONE);
		menuItem_3.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Dialog_BuyGoods buy = new Dialog_BuyGoods(shell,SWT.CLOSE | SWT.APPLICATION_MODAL);
				buy.open();
			}
		});
		menuItem_3.setText("采购商品");
		
		MenuItem menuItem_4 = new MenuItem(menu, SWT.NONE);
		menuItem_4.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Dialog_GoodType type = new Dialog_GoodType(shell,SWT.CLOSE | SWT.APPLICATION_MODAL);
				type.open();
			}
		});
		menuItem_4.setText("商品类型管理");
		
		MenuItem menuItem_5 = new MenuItem(menu, SWT.CASCADE);
		menuItem_5.setText("会员管理");
		
		Menu menu_2 = new Menu(menuItem_5);
		menuItem_5.setMenu(menu_2);
		
		MenuItem menuItem_6 = new MenuItem(menu_2, SWT.NONE);
		menuItem_6.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Dialog_RegMenber reg = new Dialog_RegMenber(shell,SWT.CLOSE | SWT.APPLICATION_MODAL);
				reg.open();
			}
		});
		menuItem_6.setText("注册会员");
		
		MenuItem menuItem_7 = new MenuItem(menu_2, SWT.NONE);
		menuItem_7.setText("会员充值");
		
		MenuItem menuItem_8 = new MenuItem(menu_2, SWT.NONE);
		menuItem_8.setText("查看会员");
		
		MenuItem menuItem_9 = new MenuItem(menu_2, SWT.NONE);
		menuItem_9.setText("积分兑换");
		
		MenuItem menuItem_10 = new MenuItem(menu_2, SWT.NONE);
		menuItem_10.setText("生日提醒");
		
		MenuItem menuItem_14 = new MenuItem(menu, SWT.CASCADE);
		menuItem_14.setText("报表管理");
		
		Menu menu_4 = new Menu(menuItem_14);
		menuItem_14.setMenu(menu_4);
		
		MenuItem menuItem_17 = new MenuItem(menu_4, SWT.NONE);
		menuItem_17.setText("年报表");
		
		MenuItem menuItem_16 = new MenuItem(menu_4, SWT.NONE);
		menuItem_16.setText("月报表");
		
		MenuItem menuItem_15 = new MenuItem(menu_4, SWT.NONE);
		menuItem_15.setText("日报表");
		
		MenuItem menuItem_11 = new MenuItem(menu, SWT.CASCADE);
		menuItem_11.setText("系统维护");
		
		Menu menu_3 = new Menu(menuItem_11);
		menuItem_11.setMenu(menu_3);
		
		MenuItem menuItem_12 = new MenuItem(menu_3, SWT.NONE);
		menuItem_12.setText("浏览管理员");
		
		MenuItem menuItem_13 = new MenuItem(menu_3, SWT.NONE);
		menuItem_13.setText("修改密码");
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/* 	项目上线时加入 	此时,注释
		//必须登录后才可以进入主界面
		if (ShoppingUtil.adminLogin == null) {
			//跳转到登录界面
			AdminLoginUI ui = new AdminLoginUI();
			shell.dispose();
			ui.open();
		}
		
		//设置标题
		shell.setText("源辰收银系统后台" + ShoppingUtil.adminLogin.get("ANAME") + "-" + ShoppingUtil.adminLogin.get("ATYPE"));
		
		*/
	}
}
